<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');

class Utils {}

// based on ideas in http://code.google.com/p/stringencoders/wiki/WebSafeBase64
function url_safe_base64($input, $direction = 'encode')
{
	if ($direction == 'encode')
	{
		$_out = base64_encode($input);
		$_out = str_replace('+', '-', $_out);
		$_out = str_replace('/', '_', $_out);
		$_out = str_replace('=', '~', $_out);
		return $_out;
	}
	elseif ($direction == 'decode')
	{
		$_out = str_replace('-', '+', $input);
		$_out = str_replace('_', '/', $_out);
		$_out = str_replace('~', '=', $_out);
		$_out = base64_decode($_out);
		return $_out;
	}
}
?>